Replication Files for The Deep Roots of Modern Democracy
Gerring, John; Apfeld, Brendan; Wig, Tore; Tollefsen, Andreas Føro

----------------------------
Directory Structure
----------------------------
├── code
│   ├── appendices
│   │   ├── appendix_a.do
│   │   ├── appendix_b.do
│   │   └── appendix_e.R
│   ├── chapter_10
│   │   ├── table_10_1.do
│   │   ├── table_10_3.do
│   │   ├── table_10_4.do
│   │   └── table_10_5.do
│   ├── chapter_11
│   │   ├── figure_11_1.do
│   │   ├── figure_11_2.R
│   │   ├── table_11_1.do
│   │   ├── table_11_2.do
│   │   ├── table_11_3.do
│   │   ├── table_11_4.do
│   │   ├── table_11_5.do
│   │   └── table_11_6.do
│   ├── chapter_12
│   │   └── tables_chapter_12.do
│   ├── chapter_13
│   │   ├── figure_13_1.R
│   │   └── tables_chapter_13.do
│   ├── chapter_14
│   │   └── tables_chapter_14.do
│   ├── chapter_16
│   │   ├── figure_16_1.R
│   │   └── figure_16_2.R
│   ├── chapter_2
│   │   ├── figure_2_1.R
│   │   ├── figure_2_3.R
│   │   ├── map_2_1.R
│   │   ├── map_2_2.R
│   │   └── table_2_1.do
│   ├── chapter_4
│   │   ├── figure_4_2.R
│   │   ├── table_4_5.R
│   │   └── table_4_6.do
│   ├── chapter_5
│   │   ├── table_5_1.do
│   │   └── table_5_2.R
│   ├── chapter_6
│   │   ├── chapter_6_tables.do
│   │   ├── figure_6_2.do
│   │   └── figure_6_3.R
│   ├── chapter_7
│   │   ├── figure_7_1.R
│   │   ├── figure_7_2.R
│   │   ├── figure_7_3.R
│   │   ├── figure_7_4.R
│   │   ├── table_7_2.do
│   │   ├── table_7_3.do
│   │   ├── table_7_4.do
│   │   ├── table_7_5.R
│   │   ├── table_7_6.do
│   │   └── table_7_7_8.R
│   ├── chapter_9
│   │   ├── figure_9_2.R
│   │   ├── figure_9_3.R
│   │   ├── map_9_1.R
│   │   └── table_9_1.do
│   ├── vcode_function.R
│   └── vcode_to_country.R
├── data
│   ├── city_herfendahl.dta
│   ├── Demo_book_country_3.dta
│   ├── Demo_book_country_3.dta.gz
│   ├── Demo_book_country_4_1600.dta
│   ├── Demo_book_country_4_1600.dta.gz
│   ├── demography_data_smoothed.Rdata
│   ├── dist2suitable.dta
│   ├── ethnographic_atlas_fixed.dta
│   ├── grid_data.Rdata
│   ├── grid_data.Rdata.gz
│   ├── Grid_size_analysis.R
│   ├── hariri_9_7.dta
│   ├── Hydepop
│   │   └── hyde31_final
│   ├── hydepop_1900_1940.dta
│   ├── Hydepop.tar.gz
│   ├── LandCover_GRID_CELL_v9_reduced.dta
│   ├── LandCover_GRID_CELL_v9_reduced.dta.gz
│   ├── LandCover_GRID_CELL_v9_reduced_notpanel.dta
│   ├── LandCover_GRID_CELL_v9_reduced_notpanel.dta.gz
│   ├── LandCover_GRID_CELL_v9_short.dta
│   ├── LandCover_GRID_CELL_v9_short.dta.gz
│   ├── Legislatures, British No America.dta
│   ├── mapdata.dta
│   ├── natharbgrid.dta
│   ├── ocdist_16.Rdata
│   ├── old cities.dta
│   ├── olsson_9_7.dta
│   ├── Parliaments_lee_v4.csv
│   ├── Pgrid.csv
│   ├── predictports.dta
│   ├── predportout.dta
│   ├── priogrid2wpi.dta
│   ├── shapefiles
│   │   ├── CShapes-2.0.dbf
│   │   ├── CShapes-2.0.fix
│   │   ├── CShapes-2.0.prj
│   │   ├── CShapes-2.0.shp
│   │   ├── CShapes-2.0.shx
│   │   ├── maps1946_2018.dbf
│   │   ├── maps1946_2018.prj
│   │   ├── maps1946_2018.shp
│   │   ├── maps1946_2018.shx
│   │   ├── priogrid_cell.dbf
│   │   ├── priogrid_cell.prj
│   │   ├── priogrid_cell.qpj
│   │   ├── priogrid_cell.shp
│   │   ├── priogrid_cell.shx
│   │   └── Spatial Data
│   ├── table_6.dta
│   ├── vcode-names2.csv
│   ├── vnames.csv
│   ├── wiki_links.xlsx
│   ├── woodberry_9_7.dta
│   └── Wvs_analysis.Rdata
├── Makefile
├── output
└── README.TXT



----------------------------
Requirements:
----------------------------
R Packages:
- ISLR
- RColorBrewer
- ROCR
- SDMTools
- StatMeasures
- caTools
- cshapes
- data.table
- devtools
- dplyr
- dotwhisker
- dummies
- gam
- ggmap
- ggplot2
- glmnet
- gtools
- haven
- magrittr
- maps
- maptools
- mediation
- pROC
- raster
- rgdal
- rgeos
- rio
- separationplot
- sp
- stringi
- tidyr
- tidyverse
- velox (github.com/hunzikp/velox)
- verification
- zoo

Other:
- rgdal requires a local installation of gdal
- cshapes requires a local installation of V8, jq, sf, terra

----------------------------
Data files
----------------------------
Some very large files have been compressed using gzip. Unzip using gunzip or similar prior to running replication analysis.

----------------------------
Code
----------------------------
We assume that you utilize the project directory as your working directory for running all scripts. For example, if you want to replicate Figure 2.1, you would run R CMD BATCH --no-save --no-restore code/chapter_2/figure_2_1.R starting in the same directory as this README.TXT file.

Code will output to a directory called output, also at the project root level. Please ensure that this directory exists before running replication code to avoid errors.

A Makefile has been provided to simplify replication. Default target is help, which documents all available targets.
